package com.atguigu.scala.chapter5

/**
 * @author lizikuan
 * @date 2021/5/21 16:47
 */
object $06_ControlAbstract {
  def main(args: Array[String]): Unit = {
    var n =1
    myWhile({
      n<10
    },{
      println(s"n=${n}")
      n+=1
    })

    loop(5)({
      println("123")
    })

  }

  def loop(n:Int)(op: => Unit):Unit = {
    if (n>0) {
      op
      loop(n-1)(op)
    }
  }

  def myWhile(condition: => Boolean,loop: => Unit):Unit = {
    if(condition) {
      loop
      myWhile(condition,loop)
    }
  }

}
